package dev.ideas.funkyj.sequence;

import org.junit.Assert;
import org.junit.Test;

import static dev.ideas.funkyj.sequence.Sequence.*;


/**
 */
public class ToFlat {

    @Test
    public void flat() {
        final Sequence<Integer> ints = from(range(1, 5));

        Assert.assertTrue(ints.to(sum).get().equals(15));
        Assert.assertTrue(ints.to(mulI).get().equals(120));
        Assert.assertTrue(ints.to(minI).get().equals(1));
        Assert.assertTrue(ints.to(maxI).get().equals(5));
    }

    @Test
    public void flatReuseSequence() {
        final Sequence<Integer> ints = from(range(1, 5));

        Assert.assertTrue(ints.to(sum).get().equals(15));
        Assert.assertTrue(ints.to(mulI).get().equals(120));
        Assert.assertTrue(ints.to(minI).get().equals(1));
        Assert.assertTrue(ints.to(maxI).get().equals(5));
    }
}
